package com.wzh.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class CommonUtil {

	public static Boolean deParma(String parma){
		Boolean res=true;
		StringBuffer sbu = new StringBuffer();
		char[] chars = parma.toCharArray();
		String time="";
		for (int i = 0; i < chars.length; i++) {
			if (i<5){
				time+=chars[4-i];
			}
			if(i>36){
				time+=chars[i];
			}
			if (i>4&&i<15){
				//判断acsii
				if (i%2!=0){
					System.out.println((int)chars[i]);
					if((int)chars[i]%2==0){
						System.out.println("偶数位正确");
					}else{
						System.out.println("偶数位不正确");
						res=false;
					}
				}else{
					if((int)chars[i]%2==0){
						System.out.println("奇数位不正确");
						res=false;
					}else{
						System.out.println("奇数位正确");
					}
				}
			}
		}

 		String nowtime="";
		for (int i = 0; i < time.length(); i++) {
			nowtime+=(char)((int)time.charAt(i)-17);
			//System.out.println((char)((int)time.charAt(i)-17));
		}
		System.out.println("参数的时间："+nowtime);

		Date date=new Date();
		long nowdate =date.getTime()/1000;
		System.out.println("当前时间："+nowdate);

		Integer nowtime2= Integer.parseInt(nowtime);
		System.out.println(nowtime2);
		if (nowtime2+15>nowdate){
			System.out.println("时间验证成功");
		}else{
			System.out.println("时间验证失败");
			res=false;
		}

		return res;
	}


	public static Long getUUID(){
		String replace = UUID.randomUUID().toString().replace("-", "");
		return Long.parseLong(replace);
	}

	public static String getNowTime(){
		Date d = new Date();
		SimpleDateFormat sbf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		//System.out.println(sbf.format(d));
		return  sbf.format(d);
	}
}
